package com.ken.autocode.tools.generator.util;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//Entity信息
public class  EntityTpl {
	
	private String tablename; //数据表名
	
	private String pkColumn ; 
	private String tablecomment; //数据表注释
	
	private String className; // Entity Class Name

	private String classObjectName; //EntityClass名称的第一个字母小写

	private String classMiniName;  //类名小写

	private String folderName;//className toLower

	private String author; //作者

	private String  moduleName;    //一级标题

	private String sqlLitePackageName;//生成sqlLite 实体类的包路径


	//工程包路径
	private String entityPackage; // entity包名
	private String mapperInterfacePackage; // mapper包名
	private String mapperXmlPackage; // mapper.xml包名
	private String servicePackage; // service包名
	private String serviceImplPackage; // serviceImpl包名
	private String controllerPackage; // controller包名
	private String viewPackage; // controller包名

	private String version ;//版本号
	private String proName ;//项目名
	private String title ; //头部所属
	
	private Date date = new Date(); // Java文件创建的时间

	private List<RecordInfo> records; // Entity对应的字段信息

	private List<RecordInfo> pkRecords; // Entity对应的主键信息

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getProName() {
		return proName;
	}

	public void setProName(String proName) {
		this.proName = proName;
	}


	private List<List<RecordInfo>> groups;//字段分组

	/**
	 * 获得主键
	 * @return
	 */
	public List<RecordInfo> getPkRecords() {
		if (pkRecords == null && records != null) {
			pkRecords = new ArrayList<RecordInfo>();
			for (RecordInfo r : records) {
				if (r.getPk()) {
					pkRecords.add(r);
				}
			}
		}
		return pkRecords;
	}

	public void addRecord(RecordInfo record) {
		if (records == null) {
			records = new ArrayList<RecordInfo>();
		}
		records.add(record);
	}


	public String getClassName() {
		return className;
	}

	public String getClassObjectName() {
		if(className!=null)
		{
			char oldChar = className.charAt(0);

			char newChar = (oldChar + "").toLowerCase().charAt(0);

			classObjectName = className.replace(oldChar, newChar);
		}
		return classObjectName;
	}

	public void setClassObjectName(String classObjectName) {
		this.classObjectName = classObjectName;
	}


	public String getServicePackage() {
		return servicePackage;
	}

	public void setServicePackage(String servicePackage) {
		this.servicePackage = servicePackage;
	}

	public Date getDate() {
		return this.date;
	}


	public List<RecordInfo> getRecords() {
		return records;
	}

	public void setClassName(String className) {
		this.className = className;
	}


	public void setRecords(List<RecordInfo> records) {
		this.records = records;
	}

	public String getTablename() {
		return tablename;
	}

	public void setTablename(String tablename) {
		this.tablename = tablename;
	}

	public String getTablecomment() {
		return tablecomment;
	}

	public void setTablecomment(String tablecomment) {
		this.tablecomment = tablecomment;
	}

	public String getFolderName() {
		return this.className.toLowerCase();
	}

	public void setFolderName(String folderName) {
		this.folderName = folderName;
	}

	public String getSqlLitePackageName() {
		return sqlLitePackageName;
	}

	public void setSqlLitePackageName(String sqlLitePackageName) {
		this.sqlLitePackageName = sqlLitePackageName;
	}

    /**
     * Getter method for property <tt>pkColumn</tt>.
     * 
     * @return property value of pkColumn
     */
    public String getPkColumn() {
        return pkColumn;
    }

    /**
     * Setter method for property <tt>pkColumn</tt>.
     * 
     * @param pkColumn value to be assigned to property pkColumn
     */
    public void setPkColumn(String pkColumn) {
        this.pkColumn = pkColumn;
    }

	public String getServiceImplPackage() {
		return serviceImplPackage;
	}

	public void setServiceImplPackage(String serviceImplPackage) {
		this.serviceImplPackage = serviceImplPackage;
	}

	public String getModuleName() {
		return moduleName;
	}

	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAuthor() {
		return author;
	}

	public String getClassMiniName() {
		return classMiniName;
	}

	public void setClassMiniName(String classMiniName) {
		this.classMiniName = classMiniName;
	}

	public String getEntityPackage() {
		return entityPackage;
	}

	public void setEntityPackage(String entityPackage) {
		this.entityPackage = entityPackage;
	}

	public String getMapperInterfacePackage() {
		return mapperInterfacePackage;
	}

	public void setMapperInterfacePackage(String mapperInterfacePackage) {
		this.mapperInterfacePackage = mapperInterfacePackage;
	}

	public String getMapperXmlPackage() {
		return mapperXmlPackage;
	}

	public void setMapperXmlPackage(String mapperXmlPackage) {
		this.mapperXmlPackage = mapperXmlPackage;
	}

	public String getControllerPackage() {
		return controllerPackage;
	}

	public void setControllerPackage(String controllerPackage) {
		this.controllerPackage = controllerPackage;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setPkRecords(List<RecordInfo> pkRecords) {
		this.pkRecords = pkRecords;
	}

	public String getViewPackage() {
		return viewPackage;
	}

	public void setViewPackage(String viewPackage) {
		this.viewPackage = viewPackage;
	}

	public List<List<RecordInfo>> getGroups() {
		return groups;
	}

	public void setGroups(List<List<RecordInfo>> groups) {
		this.groups = groups;
	}
}
